package com.hiabr.iep.admin.enums;

import java.util.stream.Stream;

public enum TenantStatusEnum {
    OK(0, "正常"),
    BAN(1, "禁用"),
    EXPIRED(2, "过期"),
    ;

    public final Integer code;
    public final String name;

    TenantStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code取枚举对象
     *
     * @param code
     * @return
     */
    public static TenantStatusEnum getByCode(String code) {
        return Stream.of(TenantStatusEnum.values())
                .filter(enum_ -> enum_.code.equals(code))
                .findAny()
                .orElse(null);
    }
}
